import React from 'react';
import {HashRouter as Router,Route,Switch,Link,useParams} from 'react-router-dom';

// https://reacttraining.com/react-router/web/example/basic  官网案例：URL Parameters
export default function IRouter(){
    return (
        <Router>
            <div>
                <ul>
                    <li>
                        <Link to="/">Home</Link>
                    </li>
                    <li>
                        <Link to="/about">About</Link>
                    </li>
                    <li>
                        <Link to="/dashboard">Dashboard</Link>
                    </li>
                </ul>
                <hr></hr>
                <Switch>
                    <Route path="/:id" children={<Child />}></Route>
                </Switch>
            </div>
        </Router>
    )
}

function Child(){
    let {id} = useParams();
    return (
        <div>
            <h3>ID:{id}</h3>
        </div>
    );
}